home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 371 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.9 KB

  1. From: kanze@gabi.gabi-soft.fr (J. Kanze)
  2. Message-ID: <KANZE.96Feb9171756@gabi.gabi-soft.fr>
  3. X-Original-Date: 09 Feb 1996 16:17:56 GMT
  4. Path: in2.uu.net!bounce-back
  5. Date: 10 Feb 96 09:04:59 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Return-Path: <daemon@meeker.UCAR.EDU>
  8. Newsgroups: comp.std.c++
  9. Subject: Re: An STL helper -- and template and type shenanigans
  10. Organization: GABI Software, Sarl.
  11. References: <01BAEFD6.AD7E8620@dino.int.com>
  12.     <KANZE.96Feb1141158@slsvewt.lts.sel.alcatel.de>
  13.     <4eto87$9kf@hermes.synopsys.com>
  14. In-Reply-To: jbuck@Synopsys.COM's message of 05 Feb 1996 09:22:02 PST
  15. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  16.     iQBFAgUBMRxf1+EDnX0m9pzZAQGAAgGAiha/4lkZUfQ9NsT5nX9ydHVgcQCyCYZi
  17.     GQUMjtuP9c2nVvYtdWHdfQIotwjQgU8F
  18.     =SpyR
  19.  
  20. In article <4eto87$9kf@hermes.synopsys.com> jbuck@Synopsys.COM (Joe
  21. Buck) writes:
  22.  
  23. > kanze@lts.sel.alcatel.de (James Kanze US/ESC 60/3/141 #40763) writes:
  24. > >In fact, this is a weakness in the STL definition (IMHO).  STL
  25. > >containers require *real* copy constructors, that actually copy.  For
  26. > >something like auto_ptr, this is not reasonable.
  27. > The *language*, not just STL, requires copy constructors that actually
  28. > copy.  The language automatically uses the copy constructor whenever it
  29. > needs to make a copy.  The copy constructor is used to return objects from
  30. > functions and to pass them in by value.  This usaga assumes that you get
  31. > an actual copy.  Copy constructors can be optimized away in certain
  32. > circumstances.  Again, this optimization works based on the assumption
  33. > that a copy constructor does a copy, so you can avoid the copy by
  34. > constructing the object in the right place.  It also means that having a
  35. > side effect in the copy constructor (other than something that preserves
  36. > copy semantics, like reference counting and such) is going to break
  37. > things.
  38.  
  39. In all cases where the language (outside of the library) does an
  40. implicite copy, the object being copied is destructed immediately after,
  41. before the user can use it for anything else.  So a `copy' that in fact
  42. `moves' will still work.
  43.  
  44. This is also the case in STL when it resizes a vector, for example.
  45.  
  46. In fact, in the particular example, I don't think that there is a real
  47. problem either.  The user asked for something that the language
  48. (including library) simply doesn't support; he wanted a vector of 10
  49. auto_ptr's all pointing to the same object.  This is a contradiction.
  50. It would be nice if this were made to require a diagnostic, but I don't
  51. see how it would be possible.
  52. -- 
  53. James Kanze           (+33) 88 14 49 00          email: kanze@gabi-soft.fr
  54. GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
  55. Conseils, itudes et rialisations en logiciel orienti objet --
  56.               -- A la recherche d'une activiti dans une region francophone
  57. ---
  58. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  59.   Contact address: std-c++-request@ncar.ucar.edu.  Moderation policy:
  60.   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html. ]
  61.